home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / clipss.zip / QUITIT.PRG < prev    next >
Text File  |  1991-09-19  |  4KB  |  137 lines

  1. /*****
  2.  *
  3.  * QUITIT.PRG
  4.  * General purpose EXIT warning box
  5.  *
  6.  * Luiz F. Quintela
  7.  * Copyright (c) 1991 Nantucket Corporation.
  8.  *                    All Rights Reserved.
  9.  *
  10.  * RMAKE 789
  11.  *
  12.  */
  13.  
  14. #include "inkey.ch"
  15.  
  16. #define        CONTINUE             2
  17. #define        QUIT                 1
  18.  
  19. FUNCTION ExitBox( nTop, nLeft, bBlock, cTitle,;
  20.                   nWait, bSaver )
  21.    LOCAL cScr, cClr, cLine, nKey, nOpt, cButScr
  22.    LOCAL aQuit, aCont
  23.    LOCAL lBlink := SETBLINK(.F.)
  24.  
  25.    // If you are going to use this function in
  26.    // your programs, take special care about colours
  27.    // since I am always using SETBLINK(FALSE)
  28.  
  29.    nTop   := IF(nTop == NIL, 10, nTop)
  30.    nLeft  := IF(nLeft == NIL, 18, nLeft)
  31.    bBlock := IF(bBlock == NIL, {|| .F.}, bBlock)
  32.    cTitle := IF(cTitle == NIL, "", cTitle)
  33.    nWait  := IF(nWait == NIL, 0, nWait)
  34.    bSaver := IF(bSaver == NIL, {|| .F.}, bSaver)
  35.  
  36.    aQuit := CreateButtom( nTop + 5, nLeft + 7, "E^xit" )
  37.    aCont := CreateButtom( nTop + 5, nLeft + 18, "^Continue" )
  38.  
  39.    DISPBEGIN()
  40.    cScr := SAVESCREEN( nTop, nLeft, nTop + 8, nLeft + 36)
  41.    cClr := SETCOLOR("N/W")
  42.  
  43.    Shadow( nTop + 1, nLeft + 2, nTop + 8, nLeft + 36)
  44.    SCROLL( nTop, nLeft, nTop + 7, nLeft + 34)
  45.    @ nTop,nLeft SAY " - " COLOR "W+/N*"
  46.    @ nTop,nLeft + 3 SAY " Exit " + ;
  47.                   SUBSTR(cTitle + SPACE(26), 1, 26) ;
  48.                   COLOR "N/GR*"
  49.    @ nTop + 2,nLeft + 4  SAY "Do you really want to Exit?"
  50.  
  51.    // Paint buttons
  52.    SelectButtom(aQuit)
  53.    UnSelectButtom(aCont)
  54.  
  55.    // Save last line
  56.    cLine := SAVESCREEN( MAXROW(), 0, MAXROW(), MAXCOL() )
  57.    @ MAXROW(), 0 SAY SPACE(MAXCOL() + 1) COLOR "W+/BG"
  58.    @ MAXROW(), 0 SAY "Press Enter to exit the " + cTitle +;
  59.                     " program or ESC to resume"
  60.    DISPEND()
  61.  
  62.    nOpt := QUIT
  63.    WHILE .T.
  64.       IF nOpt == QUIT
  65.          DISPBEGIN()
  66.          SelectButtom(aQuit )
  67.          UnSelectButtom(aCont)
  68.          @ MAXROW(), 0 SAY SPACE(MAXCOL() + 1) COLOR "W+/BG"
  69.          @ MAXROW(), 0 SAY "Press Enter to exit the " +;
  70.                           cTitle +;
  71.                           " program or ESC to resume" ;
  72.                           COLOR "W+/BG"
  73.          DISPEND()
  74.  
  75.       ELSE
  76.          DISPBEGIN()
  77.          UnselectButtom(aQuit)
  78.          SelectButtom(aCont)
  79.          @ MAXROW(), 0 SAY SPACE(MAXCOL() + 1) COLOR "W+/BG"
  80.          @ MAXROW(), 0 SAY "Press Enter to resume the " +;
  81.                           cTitle +; 
  82.                           " program" COLOR "W+/BG"
  83.          DISPEND()
  84.  
  85.       ENDIF
  86.       WHILE ((nKey := WhatKey( nWait, bBlock)) == 0)
  87.          EVAL( bSaver )
  88.  
  89.       END
  90.       IF nKey == K_TAB
  91.          nOpt := IF(nOpt == QUIT, CONTINUE, QUIT)
  92.  
  93.       ELSEIF UPPER(CHR(nKey)) == "X"
  94.          UnSelectButtom(aQuit)
  95.          UnSelectButtom(aCont)
  96.          SelectButtom(aQuit)
  97.          PressButtom(aQuit)
  98.          nOpt := QUIT
  99.          EXIT
  100.  
  101.       ELSEIF UPPER(CHR(nKey)) == "C"
  102.          UnSelectButtom(aQuit)
  103.          UnSelectButtom(aCont)
  104.          SelectButtom(aCont)
  105.          PressButtom(aCont)
  106.          nOpt := CONTINUE
  107.          EXIT
  108.  
  109.       ELSEIF nKey == K_ENTER
  110.          IF nOpt == QUIT
  111.             PressButtom(aQuit)
  112.  
  113.          ELSE
  114.             PressButtom(aCont)
  115.  
  116.          ENDIF
  117.          EXIT
  118.  
  119.       ELSEIF nKey == K_ESC
  120.          UnSelectButtom(aQuit)
  121.          UnSelectButtom(aCont)
  122.          SelectButtom(aCont)
  123.          PressButtom(aCont)
  124.          nOpt := CONTINUE
  125.          EXIT
  126.  
  127.       ENDIF
  128.  
  129.    END
  130.    RESTSCREEN( nTop, nLeft, nTop + 8, nLeft + 36, cScr )
  131.    RESTSCREEN( MAXROW(), 0, MAXROW(), MAXCOL() + 1, cLine )
  132.    SETCOLOR( cClr )
  133.    SETBLINK(lBlink)
  134.    RETURN (nOpt == QUIT)
  135.  
  136. // EOF - QUITIT.PRG //
  137.